package com.example.demo_restful.controller;

import org.springframework.web.bind.annotation.*;
import com.example.demo_restful.entity.User;

@RestController
@RequestMapping(value = "/users")
public class UserController {
    @GetMapping("/")
    public String getUserList(){
        return "所有用户列表";
    }

    @GetMapping("/{id}")
    public String getUser(@PathVariable Long id){
        return "指定id的用户" + id.toString();
    }

    @PostMapping{"/"}
    public String postUser(@RequestBody User user){
        System.out.println(user.getName());
        return "新增一个用户" + user.toString();
    }

    @PutMapping{"/{id}"}
    public String putUser(@PathVariable Long id,@RequestBody User user){
        return "更新一个用户" + toString();
    }

}

